float3 fvEyePosition;
float4x4 matViewProjection;
float4x4 world;
float fNearClipPlane;
float fFarClipPlane;

struct VS_INPUT 
{
   float4 Position : POSITION0;
   float2 Texcoord : TEXCOORD0;
   float3 Normal :   NORMAL0;
   
};

struct VS_OUTPUT 
{
   float4 Position :        POSITION0;
   float2 Texcoord :        TEXCOORD0;
   float3 Normal :          TEXCOORD3;
   
};

VS_OUTPUT VS_MAIN( VS_INPUT Input )
{
   VS_OUTPUT Output;

   Output.Position = mul( Input.Position, world );
   
   Output.Normal           = Output.Position;
   Output.Position = mul( Output.Position, matViewProjection );
   Output.Texcoord         = Input.Texcoord;
      
   return( Output );
   
}



struct PS_INPUT 
{
   float2 Texcoord :        TEXCOORD0;
   float3 Normal :          TEXCOORD3;
   
};

float4 PS_MAIN( PS_INPUT Input ) : COLOR0
{  
   float entfernung = length(Input.Normal - fvEyePosition);
   float ecolor = 1.0f-((entfernung - fNearClipPlane) / (fFarClipPlane-fNearClipPlane));
   float4 color = float4(ecolor, ecolor, ecolor, 1.0f);
      
   return( color);
      
}





//--------------------------------------------------------------//
// Technique Section for Tiefenshader
//--------------------------------------------------------------//
technique Tiefenshader
{
   pass Pass_0
   {
      VertexShader = compile vs_2_0 VS_MAIN();
      PixelShader = compile ps_2_0 PS_MAIN();
   }

}




